package ua.edu.nuos.jeetraining2012.cms.ui.events;

import com.vaadin.navigator.Navigator;
import com.vaadin.ui.MenuBar;

/**
 * Created with IntelliJ IDEA.
 * User: mody
 * Date: 08.06.13
 * Time: 5:53
 * To change this template use File | Settings | File Templates.
 */
public class AdminMenuBarCommand {

    private String viewName;
    private Navigator navigator;
    private MenuBar.Command command;

    public AdminMenuBarCommand(String viewName, Navigator navigator) {
        this.navigator = navigator;
        this.viewName = viewName;
    }

    public MenuBar.Command menuSelected() {
        command = new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem menuItem) {
                navigator.navigateTo(viewName);
            }
        };
        return command;
    }
}
